import axios from 'axios'
// var qs = require('qs')
const host = 'http://tft-dev/api4'

// 查询售后申请列表
export function findAfterSales (data) {
  const url = `${host}/com/thishop/module/afterSell/applicationFind`
  return axios.post(url, data)
    .then(res => {
      return Promise.resolve(res.data)
    })
}
// 查询退换货列表
export function findReturn (data) {
  const url = `${host}/com/thishop/module/afterSell/returnGoodFind`
  return axios.post(url, data)
    .then(res => {
      return Promise.resolve(res.data)
    })
}
// 新增退货原因
export function increaseReason (data) {
  const url = `${host}/com/thishop/module/afterSellReason/create`
  return axios.post(url, data)
    .then(res => {
      return Promise.resolve(res.data)
    })
}
// 查询退货原因列表
export function findReason (data) {
  const url = `${host}/com/thishop/module/afterSellReason/findReason`
  return axios.post(url, data)
    .then(res => {
      return Promise.resolve(res.data)
    })
}
// 编辑退货原因
export function EditReason (data) {
  const url = `${host}/com/thishop/module/afterSellReason/update`
  return axios.post(url, data)
    .then(res => {
      return Promise.resolve(res.data)
    })
}

//------------------------------------退款管理-------------------------------------
// 退款页面查询
export function selectAfterSell (data) {
  const url = `${host}/com/thishop/module/afterSell/returnMoneyFind`
  return axios.post(url, data).then(res => {
    return Promise.resolve(res.data)
  })
}

// 认领 退款，退货退货，换货
export function claimRefund (afterSellId, data) {
  const url = `${host}/com/thishop/module/afterSell/${afterSellId}/takeDeal`
  return axios.post(url, data).then(res => {
    return Promise.resolve(res.data)
  })
}

// 退换货，退款 编辑页修改状态
export function editRefundStatus (afterSellId, data) {
  const url = `${host}/com/thishop/module/afterSell/${afterSellId}/updateStatus`
  return axios.post(url, data).then(res => {
    return Promise.resolve(res.data)
  })
}

//------------------------------------操作记录-------------------------------------
// 操作记录页面查询
export function selectOperateRecord (afterSellId) {
  const url = `${host}/com/thishop/module/afterSell/${afterSellId}/find`
  return axios.post(url).then(res => {
    return Promise.resolve(res.data)
  })
}
